package zz.app.ustbgsmanager.widgets;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import zz.app.ustbgsmanager.R;

/**
 * Created by zz on 2018/6/2 17:34.
 */
public class IndexButton extends FrameLayout {
    String title;
    Drawable icon;
    ImageView imageView;
    TextView textView;

    public IndexButton(Context context) {
        super(context);
    }

    public IndexButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.index_button_layout, this, true);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IndexButton);
        title = typedArray.getString(R.styleable.IndexButton_indexButtonTitle);
        icon = typedArray.getDrawable(R.styleable.IndexButton_indexButtonSrc);
        typedArray.recycle();
        imageView = findViewById(R.id.imgIcon);
        textView = findViewById(R.id.tvTitle);
        imageView.setImageDrawable(icon);
        textView.setText(title);
        setClickable(true);
        setFocusable(true);

    }
}
